ExternalProject_Add(llvm-compiler-rt
    DEPENDS
        llvm-libcxx
    DOWNLOAD_COMMAND ""
    UPDATE_COMMAND ""
    SOURCE_DIR ${LLVM_SRC}
    CONFIGURE_ENVIRONMENT_MODIFICATION
        _IS_CONFIGURE=set:1
    CONFIGURE_COMMAND ${EXEC} ${CMAKE_COMMAND} -H<SOURCE_DIR>/compiler-rt -B<BINARY_DIR>
        ${cmake_conf_args}
        -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}/lib/clang/${clang_version}
        -DCMAKE_C_COMPILER_TARGET=${TARGET_CPU}-pc-windows-gnu
        -DCMAKE_DISABLE_FIND_PACKAGE_LLVM=ON
        -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON
        -DCOMPILER_RT_USE_BUILTINS_LIBRARY=ON
        -DCOMPILER_RT_BUILD_BUILTINS=OFF
        -DCOMPILER_RT_INCLUDE_TESTS=OFF
        -DSANITIZER_CXX_ABI=libc++
        -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
        -DCOMPILER_RT_TARGET_HAS_ATOMICS=ON
        -DCOMPILER_RT_TARGET_HAS_FLOCK=ON
        -DCOMPILER_RT_BUILD_LIBFUZZER=OFF
        -DCOMPILER_RT_BUILD_SANITIZERS=OFF
        -DCOMPILER_RT_BUILD_ORC=OFF
        -DCOMPILER_RT_HAS_UBSAN=OFF
        -DCOMPILER_RT_HAS_VERSION_SCRIPT=OFF
        -DCOMPILER_RT_SANITIZERS_TO_BUILD=''
        -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY
    BUILD_ENVIRONMENT_MODIFICATION
        _PACKAGE_NAME=set:${package}
        _BINARY_DIR=set:<BINARY_DIR>
        _LTO_ENABLED=set:0
        _PGO_ENABLED=set:0
        _IS_RTTI_ALLOWED=set:1
        _NOCCACHE=set:1
    BUILD_COMMAND ${EXEC} ninja -C <BINARY_DIR>
    INSTALL_COMMAND ${EXEC} ${CMAKE_COMMAND} --install <BINARY_DIR>
    LOG_DOWNLOAD 1 LOG_UPDATE 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1
)
cleanup(llvm-compiler-rt install)
